<!DOCTYPE html>
<%@ include file="../base.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>资金流水</title>
<link rel="stylesheet" href="${ctx}/assets/css/reset.css?v=1.0.1" />
<link rel="stylesheet" href="${ctx}/assets/css/pullToRefresh.css?v=1.0.1" />
<script src="${ctx}/assets/js/iscroll.js?v=1.0.1"></script>
<script src="${ctx}/assets/js/pullToRefresh.js?v=1.0.1"></script>
<%@ include file="../js.jsp"%>
</head>
<body ontouchstart>
	<input type="hidden" id="rowCount" value="${pageView.rowCount }">
	<div class="bd" id="wrapper">
        <ul id="thelist" class="weui_cells">
        </ul>
    </div>
    
    
</body>
<script type="text/javascript">
	var pageNo=1;
	var pageSize=10;
	var pageCount=0;
	var memberId = '${memberId}';
	var hqId = '${hqId}';

	$(function(){
		getCnt();
	});
	
	function getCnt() {
	   	$.ajax({
		      type: "POST",
		      url: "${ctx}/member/details",
		      data: {pageNo:pageNo,pageSize:pageSize,memberId:memberId,hqId:hqId},
		      success: function(data){
		    	pageCount = data.pageCount;
		    	Load();
		      }
		   });
		}
</script>

<script type="text/javascript">
 refresher.init({
     id: "wrapper",
     pullDownAction: Refresh,
     pullUpAction: Load
 });
 
 function Refresh() {
     setTimeout(function () {
    	 wrapper.refresh();
     }, 1000);

 }

 function Load() {
     setTimeout(function () {
        var el, li, i;
        el = document.querySelector("#wrapper ul");
    	if(pageCount<pageNo){
    		/* var pullDownEl = wrapper.querySelector(".pullDown");
    		pullDownEl.querySelector('.pullDownLabel').innerHTML = "已至最后一页"; */
    		if(pageCount==pageNo-1){
    			var $ul = $("#wrapper ul");             	
              	var $htmlLi = $("<li class='weui_cell'><p class=\"data-end\">没有更多数据</p></li>"); 
              	$ul.append($htmlLi);
    			/* result =  " <p class=\"data-end\">没有更多数据</p>";
  	    		li = document.createElement('li');
  	    		li.setAttribute("class", "weui_cell");
                li.innerHTML=result;
              	el.appendChild(li, el.childNodes[0]); */
              	pageNo++;
    		}
        	wrapper.refresh();
			return;
		}
    	$.ajax({
	  	      type: "POST",
	  	      url: "${ctx}/member/details",
	  	      data: {pageNo:pageNo,pageSize:pageSize,memberId:memberId,hqId:hqId},
	  	      success: function(data){
	  	    	var result = '';
	  	    	  if(data.code == 200){
	  	    		$.each(data.records, function(name, value) {
	  	    			result = 
		                     "<div class=\"weui_cell_bd weui_cell_primary\">"+
		                         "<p>"+this.amountTypeName
		                         +" <span class=\"navi-address\">余额:"+this.balanceAmount+"元</span></p>"+
		                     "</div>"+
		                     "<div class=\"weui_cell_ft\">"+
		                        " <p>"+this.createdTime;
		                        
		                        if(this.amount <= 0){
		                        	result+="<span class=\"balance-pay text-green\">"+this.amount+"元</span>"
		                        }else{
		                        	result+="<span class=\"balance-pay text-red\">+"+this.amount+"元</span>"
		                        }
                        result+="</p></div>";
                        /*li = document.createElement('li');
	  	  	    		li.className += 'weui_cell';
	  	                li.innerHTML=result;
	  	              	el.appendChild(li, el.childNodes[0]); */
  	    			 	var $resultLi = "<li class=\"weui_cell\">"+result+"</li>";
	  	    			var $ul = $("#wrapper ul");             	
		              	$ul.append($resultLi);
	  	    			wrapper.refresh();
	  	    		});
	  	    		pageNo++;
	  	    	  }else{
		  	        alert("资金列表加载失败！");
	  	    	  }
	  	      }
	  	   });
     }, 1000);
     
 }
</script>
</html>